home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / dcontkit.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  5KB  |  175 lines

  1. #include "dcontkit.h"
  2. #include "help.h"
  3.  
  4. void DiacomContextKit::exe(int )
  5.     {
  6.     int sub_action = 0;                            // reserv
  7.     while(1)
  8.     {
  9.     mouseShowCursor();
  10.     int res_cur = current;                     // reserv
  11.  
  12.     list[current]->exe(sub_action);    // event which can not be procecced
  13.     sub_action = 0;                        // with current object
  14.  
  15.     if(!current)                           // after pressing on 0th window
  16.         {                                  // - proceed with 1th
  17.         shift();
  18.         showStatus(1);
  19.         continue;
  20.         }
  21.  
  22.     if(global_i[0])            // if exe() sets action_type to global_i[0]
  23.         {
  24.         if(global_i[0] == AC_NEXT)             // command for objkit, not for any of its components
  25.         {                                  // usage: menu->find can not find the given string
  26.         moveTo(list[current]->isPoint());  // in the menu->itemList
  27.         showStatus(current);
  28.         sub_action = AC_NEXT;
  29.         continue;
  30.         }
  31.  
  32.         int res = current;                  // where to return whith ESC-like command
  33.         moveTo(list[current]->isPoint());
  34.         if(global_i[0] != AC_CANCEL)
  35.         showStatus(current);
  36.         global_num = 1;
  37.         list[current]->exe(global_i[0]); // for example: button->exe(), calls menu->exe()
  38.  
  39.             if(global_i[0] == AC_REDRAW || global_i[0] == AC_RESIZE
  40.             || global_i[0] == AC_MOVE)
  41.         {
  42.                 return;
  43.         }
  44.  
  45.         if(global_i[0] != AC_NEXT)  // return after execution, f.e. button - menu->exe(AC_LEFT) - again return to button
  46.         {
  47.         moveTo(get(list[res]));
  48.         showStatus(current);
  49.         global_num = 1;
  50.         if(list[current]->isRet(act_ret()))
  51.             {
  52.             if(global_i[0] != AC_NULL)         // if !CANCEL pressed
  53.             global_i[0] = action_type;
  54.             showStatus(used);
  55.             return;
  56.             }
  57.         }
  58.         }
  59.  
  60.     if(!global_i[0])
  61.         {
  62.         if(e.what == KEYEVENT)
  63.         {
  64.         char* ch;
  65.         if(hot != NULL
  66.             && (ch = strchr(strlwr(hot), e.keypress()))
  67.             && (e.key < 256) && e.keypress())
  68.             {
  69.             mouseHideCursor();
  70.             list[current]->show();
  71.             moveTo(ch - hot + 1);
  72.             showStatus(current);
  73.             mouseShowCursor();
  74.             continue;
  75.             }
  76.  
  77.         switch(e.key)
  78.             {
  79.             case EVENT_F1:
  80.             if(help_context)
  81.                 ::help(help_context);
  82.             break;
  83.             case EVENT_ALT_F3:
  84.             if(!isRet(RET_REMOVE))
  85.                 continue;
  86.             global_i[0] = AC_ERASE;
  87.             showStatus(used);
  88.             return;
  89.             case EVENT_ALT_F4:
  90. //            global_i[0] = AC_ERASE;
  91.             showStatus(used);
  92.             return;
  93.             case EVENT_F2:
  94.             case EVENT_RETURN:
  95.             if(list[current]->isRet(RET_REMOVE | RET_OK
  96.                         | RET_MOUSE))
  97.                 {
  98.                 global_i[0] = action_type;
  99.                             global_num = 1;
  100.                 showStatus(used);
  101.                 return;
  102.                 }
  103.             break;
  104.                     case EVENT_LEFT:
  105.                         mouseHideCursor();
  106.                 current = (current > 1) ? current - 1 : used;
  107.                         showStatus(current);
  108.                         mouseShowCursor();
  109.                 break;
  110.             case EVENT_RIGHT: mouseHideCursor(); shift();
  111.                 showStatus(current); mouseShowCursor(); break;
  112.                     case EVENT_UP:
  113.                         mouseHideCursor();
  114.                 current = (current > 6) ? current - 6 : current;
  115.                         mouseShowCursor();
  116.                 break;
  117.                     case EVENT_DN:
  118.                         mouseHideCursor();
  119.                 current = (current < 18) ? current + 6 : current;
  120.                         mouseShowCursor();
  121.                 break;
  122.  
  123.             case EVENT_TAB: mouseHideCursor(); shift();
  124.                 showStatus(current); mouseShowCursor(); break;
  125.             case EVENT_F6:
  126.             case EVENT_ALT_TAB:
  127.             case EVENT_F10:
  128.             case EVENT_ESC: global_i[0] = 0;
  129.             if(current != used)
  130.                 showStatus(used);
  131.             return;
  132.             default: break;
  133.             }
  134.         }
  135.         else
  136.         if(e.mouse1())    // mouse pressed
  137.             {
  138.             int n = 1;
  139.             if(!list[0]->mouse_in(e.where()))  // outside
  140.             {
  141.             global_i[0] = AC_CLOSE;
  142.             showStatus(used);
  143.             return;
  144.             } // mouse pressed outside
  145.             while(n != used + 1)   // where it was pressed?
  146.             {
  147.             if(list[current]->mouse_in(loc(e.where())))
  148.                 {
  149.                 if(res_cur == current
  150.                    && list[current]->isRet(RET_MOUSE))
  151.                 {
  152.                 global_i[0] = action_type;
  153.                 showStatus(used);
  154.                 return;
  155.                 }
  156.                 showStatus(current);
  157.                 break;
  158.                 }
  159.             mouseHideCursor();
  160.             shift();
  161.             mouseShowCursor();
  162.             n++;
  163.             }
  164.             if(n == used + 1)
  165.             {
  166.             current = 0;               // if background object pressed -
  167.             if(help_context)           // we check it last, and try
  168.                 ::help(help_context);  // to show help
  169.             }
  170.             }
  171.         }
  172.     }
  173.     }
  174. ////////////////////
  175.